using UnityEngine;
using UnityEngine.EventSystems;

public class UI_QuickItemSlot : UI_ItemSlot
{
    [SerializeField] private Sprite defaultSprite;
    [SerializeField] private int currentSlotNum;

    public void SetQuickSlotItem(Inventory_Item itemToSet) => playerInventory.SetQuickItemInSlot(currentSlotNum, itemToSet);
    public void UpdateQuickSlotUI(Inventory_Item itemToSet)
    {
        if (itemToSet == null || itemToSet.itemData == null)
        {
            itemIcon.sprite = defaultSprite;
            itemStackSize.text = "";
            return;
        }
        itemIcon.sprite = itemToSet.itemData.itemIcon;
        itemStackSize.text = itemToSet.stackSize > 1 ? itemToSet.stackSize.ToString() : "";
    }

    public override void OnPointerDown(PointerEventData eventData)
    {
        UI_InGame inGameUI = uI.inGameUI;
        if (inGameUI.IsOpenQuickItemOption())
        {
            inGameUI.HideQuickItemOptions();
            return;
        }
        inGameUI.OpenQuickItemOptions(this, GetComponent<RectTransform>());
    }
    public override void OnPointerEnter(PointerEventData eventData)
    {

    }
    public override void OnPointerExit(PointerEventData eventData)
    {
        
    }
}
